﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SDF.Plugin.Misc.DynamicEntity.Domain.Enums;

namespace SDF.Plugin.Misc.DynamicEntity.Common
{
    public class Tools
    {
        public static ParamDirectionEnum ConvertDirectionFromString(string directionString)
        {
            switch (directionString.ToUpper())
            {
                case "IMPORT":
                    return ParamDirectionEnum.Import;
                case "EXPORT":
                    return ParamDirectionEnum.Export;
                case "BOTH":
                    return ParamDirectionEnum.Both;
                default:
                    return ParamDirectionEnum.Unknow;
            }
        }

        public static EntityFieldTypeEnum ConvertTypeFromString(string typeString)
        {
            switch (typeString.ToUpper())
            {
                case "CLNT":
                    return EntityFieldTypeEnum.String;
                case "CHAR":
                    return EntityFieldTypeEnum.String;
                case "":
                    return EntityFieldTypeEnum.Bool;
                case "CURRENCY"://TO BE CHANGE
                    return EntityFieldTypeEnum.Currency;
                case "DATS":
                    return EntityFieldTypeEnum.Date;
                case "TIMS":
                    return EntityFieldTypeEnum.Time;
                case "DATETIME"://目前没有
                    return EntityFieldTypeEnum.DateTime;
                case "INT":
                    return EntityFieldTypeEnum.Int;
                case "STRUCTURE":
                    return EntityFieldTypeEnum.Struct;
                case "TABLE":
                    return EntityFieldTypeEnum.Collection;
                case "DEC":
                    return EntityFieldTypeEnum.String;
                default:
                    return EntityFieldTypeEnum.String;
            }
        }
    }
}